package cc.admin.modules.sys.entity;

import cc.admin.common.aspect.annotation.Dict;
import cc.admin.common.sys.vo.TenantModel;
import cc.admin.poi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * 机构表
 *
 * @Author
 * @Since  2022-07-07
 */
@Data
@TableName("sys_org")
public class SysOrg extends TenantModel implements Serializable {
	private static final long serialVersionUID = 1L;

	/**ID*/
	@TableId(type = IdType.ASSIGN_ID)
	private String id;
	/**父机构ID*/
	private String parentId;
	/**机构名称*/
	@Excel(name="机构/部门名称",width=15)
	private String name;
	/**机构编码*/
	@Excel(name="机构编码",width=15)
	private String code;
	/**排序*/
	@Excel(name="排序",width=15)
	private Integer sortBy;
	/**备注*/
	@Excel(name="备注",width=15)
	private String description;
	/**状态（1启用，0不启用）*/
	@Dict(dicCode = "org_status")
	private String status;
	/**删除状态（0，正常，1已删除）*/
	@Dict(dicCode = "del_flag")
	private String delFlag;
	/**创建人*/
	private String createBy;
	/**创建日期*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createTime;
	/**更新人*/
	private String updateBy;
	/**更新日期*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date updateTime;
	/**
	 * 重写equals方法
	 */
	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		if (!super.equals(o)) {
			return false;
		}
		SysOrg org = (SysOrg) o;
		return Objects.equals(id, org.id) &&
				Objects.equals(parentId, org.parentId) &&
				Objects.equals(name, org.name) &&
				Objects.equals(code, org.code) &&
				Objects.equals(sortBy, org.sortBy) &&
				Objects.equals(description, org.description) &&
				Objects.equals(status, org.status) &&
				Objects.equals(delFlag, org.delFlag) &&
				Objects.equals(createBy, org.createBy) &&
				Objects.equals(createTime, org.createTime) &&
				Objects.equals(updateBy, org.updateBy) &&
				Objects.equals(updateTime, org.updateTime);
	}

	/**
	 * 重写hashCode方法
	 */
	@Override
	public int hashCode() {

		return Objects.hash(super.hashCode(), id, parentId, name,
				code, description,sortBy, status,
				delFlag, createBy, createTime, updateBy, updateTime);
	}
}
